<?php
class ControllerReportSaleShipping extends AdminController {
	public function index() {

		$this->document->setTitle($this->_['heading_title']);

		$qf = new Query_filter();

		M('report/sale');

		$this->data['orders'] = array();

		$order_total = $this->model_report_sale->getTotalShipping($qf);

		$results = $this->model_report_sale->getShipping($qf);

		foreach ($results as $result) {
			$this->data['orders'][] = array(
				'date_start' => v5_date_format($result['date_start']),
				'date_end'   => v5_date_format($result['date_end']),
				'title'      => $result['title'],
				'orders'     => $result['orders'],
				'total'      => $this->currency->format($result['total'], C('config_currency'))
			);
		}

		$this->data['order_statuses'] = C('cache_order_status');

		$this->data['groups'] = array();

		$this->data['groups'][] = array(
			'text'  => $this->_['text_year'],
			'value' => 'year',
		);

		$this->data['groups'][] = array(
			'text'  => $this->_['text_month'],
			'value' => 'month',
		);

		$this->data['groups'][] = array(
			'text'  => $this->_['text_week'],
			'value' => 'week',
		);

		$this->data['groups'][] = array(
			'text'  => $this->_['text_day'],
			'value' => 'day',
		);

		$this->data['pagination'] = $this->pagination($order_total)->render();

		$this->data['filter_date_start'] = $qf->get('filter_date_start', '');;
		$this->data['filter_date_end'] = $qf->get('filter_date_end', '');;
		$this->data['filter_group'] = $qf->get('filter_group', 'week');;
		$this->data['filter_order_status_id'] = $qf->get('filter_order_status_id', 0);;

		$this->display('report/sale_shipping.tpl');
	}
}
?>